<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

</body>

</html>
<script>
    var b = 0;
    setInterval(function() {
        for (var i = 0; i <= 1; i++) {
            var a = Math.floor(Math.random() * 3);
            if (a == b) {
                i--
            } else {
                console.log(a);
                b = a;
            }
        }
    }, 2000)
</script>